package be.redo.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import be.redo.dao.AirportDAO;
import be.redo.model.entities.Airport;
import be.redo.model.entities.Region;

@Service
@Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED)
public class AirportServiceImpl implements AirportService {

	@Autowired
	AirportDAO dao;

	@Override
	@Transactional(readOnly = false)
	public void create(Airport airport) {
		dao.create(airport);

	}

	@Override
	public Airport read(long id) {
		return dao.read(id);
	}

	@Override
	@Transactional(readOnly = false)
	public void update(Airport airport) {
		dao.update(airport);
	}

	@Override
	@Transactional(readOnly = false)
	public void delete(long id) {
		dao.delete(id);

	}

	@Override
	public List<Airport> findAll() {
		return dao.findAll();
	}

	@Override
	public int count() {
		return dao.count();
	}

	@Override
	public List<Airport> findAirportsByCodeLike(String code) {
		return dao.findAirportsByCodeLike(code);
	}

	@Override
	public List<Airport> findAirportsByNameLike(String name) {
		return dao.findAirportsByNameLike(name);
	}

	@Override
	public List<Airport> findAirportsByRegion(Region region) {
		return dao.findAirportsByRegion(region);
	}

	@Override
	public Airport findAirportsByCodeEquals(String code) {
		return dao.findAirportsByCodeEquals(code);
	}

	@Override
	public List<Airport> findAirportsByFirstCharactersOfName(String name) {
		return dao.findAirportsByFirstCharactersOfName(name);
	}

}
